var mysql      = require('mysql');
var connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : '1234567',
    database : 'test'
});
//增加数据
connection.connect();


//增加item的格式匹配
var  addSql = 'insert into user(Userid,UserName,UserPassword,UserItem,UserAddress) VALUES(0,?,?,?,?)';


//增加user的接口
var  addSqlParams = ['MYX', '777','airpods','浙江杭州'];
//Mysql是UTF-8，注意把编译器的编码改成UTF-8
//userid固定，删除之后自增继续开始，保证唯一

connection.query(addSql,addSqlParams,function (err, result) {
    if(err){
        console.log('[INSERT ERROR] - ',err.message);
        return;
    }

    console.log('--------------------------INSERT----------------------------');
    //console.log('INSERT ID:',result.insertId);
    console.log('INSERT ID:',result);
    console.log('-----------------------------------------------------------------\n\n');
});

connection.end();
